import myRequest from '@/utils/myRequest'


export function getLicenseList(sort, rows, page, product_id, search_for) {
  return myRequest({
    url: '/api/license-keys',
    method: 'get',
    params: {
      sort: sort,
      rows: rows,
      page: page,
      productId: product_id,
      searchFor: search_for,
      isActivatedOnly: false
    }
  })
}

export function getLicenseExcel(sort, rows, page, product_id, search_for, isExtractingAll) {
  return myRequest({
    url: '/api/license-keys/extract/excel',
    method: 'get',
    params: {
      sort: sort,
      rows: rows,
      page: page,
      productId: product_id,
      searchFor: search_for,
      isActivatedOnly: false,
      isExtractingAll: isExtractingAll
    }
  })
}

export function getLicenseTxt(sort, rows, page, product_id, search_for, isExtractingAll) {
  return myRequest({
    url: '/api/license-keys/extract/txt',
    method: 'get',
    params: {
      sort: sort,
      rows: rows,
      page: page,
      productId: product_id,
      searchFor: search_for,
      isActivatedOnly: false,
      isExtractingAll: isExtractingAll
    }
  })
}

export function generateLicense(amount, product_api_id, duration) {
  return myRequest({
    url: '/api/license-keys/generate',
    method: 'post',
    params: {
      amount: amount,
      product_api_id: product_api_id,
      duration
    }
  })
}

export function deleteLicense(license_id) {
  return myRequest({
    url: '/api/license-keys/' + license_id,
    method: 'post',
    params: {
      action: 'delete'
    }
  })
}